package tut.topic.virtualMethod;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class VirtualDemo {
	public static void main(String[] args) {
		Salary s = new Salary("Mohd Mohtashim", "Ambehta, UP", 3, 3600.00);
		Employee e = new Salary("John Adams", "Boston, MA", 2, 2400.00);
		System.out.println("Call mailCheck using Salary reference --");
		s.mailCheck();
		System.out.println("\n Call mailCheck usingEmployee reference--");
		e.mailCheck();

		Set<Employee> set = new HashSet<Employee>();

		Employee e1, e2, e3;
		e1 = new Employee("a", "b", 1);
		set.add(e1);
		e2 = new Employee("a", "b", 2);
		set.add(e2);
		e3 = new Employee("a", "b", 1);
		set.add(e3);
		set.add(e3);
		set.add(e2);

		Iterator<Employee> it = set.iterator();
		while (it.hasNext()) {
			Employee employee = (Employee) it.next();
			System.out.println(employee);
		}

		System.out.println(e1.equals(e2));
		System.out.println(e2.equals(e3));
		System.out.println(e3.equals(e1));
	}
}
